<template>
  <div class="demo19">
    <div>
      {{num}}
      <div>
        <Button @click="resetBtnClick" :disabled="type !== 2">清零</Button>
        <Button @click="handleParse">{{type === 1?'暂停':'运行'}}</Button>

      </div>
    </div>
  </div>

</template>

<script>
  export default {
    name: 'demo19',
    components: {},
    props: {},
    data() {
      return {
        num: 0,
        timer: null,

        type: 0, // 0  初始状态  1  运行状态  2  暂停状态
      };
    },
    mounted() {
    },
    methods: {
      handleParse() {
        // 如果定时器已经存在 说明现在正在倒计时中
        if (this.timer) {
          return
        }
        this.timer = setInterval(() => {
          // 每秒+1
          this.num++
        }, 100)
       
      }
    },
    computed: {}
  };
</script>

<style scoped lang="less">
  .demo19 {
  }
</style>
<style lang="less">
  .demo19 {
  }
</style>
